//
//  XLAutoScrollView.m
//  XiangLove
//
//  Created by 李传坤 on 2018/4/19.
//  Copyright © 2018年 BAOMIHUA.COM. All rights reserved.
//

#import "XLAutoScrollView.h"
#import "AutoScrollView.h"
@interface XLAutoScrollView ()<AutoScrollViewDelegate>{
    AutoScrollView *_autoScrollView;
    XLAutoScrollViewBlocks _XLAutoScrollViewBlocks;
}
@end
@implementation XLAutoScrollView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _autoScrollView = [[AutoScrollView alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH-20, (SCREEN_WIDTH-20) * 19 / 71)  placeholderImage:[UIImage imageNamed:@"默认商品图正方形.png"] andRight:NO];
        _autoScrollView.rollingDelayTime = 3.0f;
        _autoScrollView.userInteractionEnabled = NO;
        _autoScrollView.delegate = self;
        [self addSubview:_autoScrollView];
    }
    return  self;
}
    
#pragma mark -更新数据
-(void)changeShowDict:(NSArray *)imageArr  andBlocks:(XLAutoScrollViewBlocks)shopBannerBlocks{
    _XLAutoScrollViewBlocks = [shopBannerBlocks copy];
    _autoScrollView.images = imageArr;
    [_autoScrollView startRolling];
    _autoScrollView.userInteractionEnabled = YES;
}
-(void)changeShowDict2:(NSArray *)imageArr  andBlocks:(XLAutoScrollViewBlocks)shopBannerBlocks{
    CGRect rect = _autoScrollView.frame;
    rect.size.height = (SCREEN_WIDTH*120.0f)/320.0f;
    [_autoScrollView setFrame:rect];
    _XLAutoScrollViewBlocks = [shopBannerBlocks copy];
    _autoScrollView.images = imageArr;
    [_autoScrollView startRolling];
    _autoScrollView.userInteractionEnabled = YES;
}
-(void)autoScrollView:(AutoScrollView *)autoScrollView didSelectImageIndex:(NSInteger)index{
    if ( _XLAutoScrollViewBlocks ) {
        _XLAutoScrollViewBlocks(index);
    }
}

@end
